const express = require('express');
const router = express.Router();

router.get('/', (req, res) => {
    //查询CBU整车发运单
    const content = [];
    const {pageIndex, pageSize} = req.query;
    for(let i = 1; i <= 100; i++) content.push({
        id: `${i}`,
        code: `CODE${i}`,
        dealerId: `1errq1-${i}`,
        dealerCode: `s-${i}`,
        dealerName: `s-${i}`,
        partShipmentStatus: 1,
        invoicedDate: '2020-03-17T07:21:30.070Z',
        transportType: 1,
        origin: `s-${i}`,
        destination: `s-${i}`,
        expectShipmentDay: 0,
        actualShipmentDay: 0,
        shipmentDate: `s-${i}`,
        expectShipmentDate: '2020-03-17T07:21:30.070Z',
        expectDepartedDate: '2020-03-17T07:21:30.070Z',
        actualDepartedDate: '2020-03-17T07:21:30.070Z',
        expectArrivalDate: '2020-03-17T07:21:30.070Z',
        actualArrivalDate: '2020-03-17T07:21:30.070Z',
        declarePlace: 1,
        declareType: 1,
        receipterName: `s-${i}`,
        receiptTime: `s-${i}`,
        createTime: '2020-03-17T07:21:30.070Z',
        rowVersion: 'string',
        options: ['update', 'abandon', 'signned', 'dateSupplement']
    });
    res.json(
        {
            message: '',
            payload: {
                content,
                pageIndex: parseInt(pageIndex, 10),
                pageSize: parseInt(pageSize, 10),
                totalElements: 40,
            }
        }
    );
});
router.get('/saleConfirmation', (req, res) => {
    //销售确认书查询
    const {pageIndex, pageSize} = req.query;
    res.json(
        {
            message: '',
            payload: {
                content: [
                    {
                        id: '5bd3073c-70a1-4105-86e5-08d7fba06d8c',
                        code: '10921-CBU202005N0017',
                        brandId: '305d091e-3a99-43e0-14dd-08d76bf076c5',
                        brandCode: 'CHERY',
                        brandName: 'CHERY',
                        dealerId: 'fcee2790-bf8a-4082-9b08-08d74c53a651',
                        dealerCode: '10921',
                        dealerName: 'ASIAN MOTORS W.L.L',
                        type: 1,
                        transportType: 3,
                        payment: 1,
                        tradeMethodId: 'a68d23a0-d463-4c78-8a71-08d7b37345cf',
                        createTime: '2020-05-19T02:57:54.8212695+08:00',
                        tradeMethodName: '奇瑞股份',
                        saleDeliveryOrderId: '72776dec-031f-421f-976e-2593a4f95514',
                        saleDeliveryOrderCode: '10921JHD2020051801',
                        productId: null,
                        productCode: 'A6462GABKBW0006',
                        productName: 'SQR6462A187奇瑞白舒适型5座(国Ⅳ+OBD）',
                        salesConfirmationId: '60405e87-c0ba-44e6-7219-08d7fba06d8b',
                        quantity: 1,
                        price: 30000,
                        totalPrice: 30000,
                        taxFreeTotalPrice: 79646.02,
                        vin: 'VIN00003',
                        saleDeliveryOrderDetailId: '25afec09-65bc-4b23-93e1-bd78aa89042d'
                    },
                    {
                        id: '938f8772-cdf7-4b76-c15f-08d7fb25eba0',
                        code: '12061-CBU202005N0020',
                        brandId: '305d091e-3a99-43e0-14dd-08d76bf076c5',
                        brandCode: 'CHERY',
                        brandName: 'CHERY',
                        dealerId: 'c1835909-8438-4aa7-9b0a-08d74c53a651',
                        dealerCode: '12061',
                        dealerName: 'CA AVTOMOTIV LLC',
                        type: 1,
                        transportType: 1,
                        payment: 2,
                        tradeMethodId: 'b16d92e1-09d6-4d63-8a73-08d7b37345cf',
                        createTime: '2020-05-18T12:20:58.2566114+08:00',
                        tradeMethodName: '奇瑞香港',
                        saleDeliveryOrderId: '667970db-b82c-420a-951b-92273cb7158d',
                        saleDeliveryOrderCode: '12061JHD2020051803',
                        productId: '5ed42773-dcee-46bb-a81e-e624136ab6a7',
                        productCode: 'A6468CNBKBF0002',
                        productName: 'SQR6468A1 standard model',
                        salesConfirmationId: '08e548e2-6b2b-4426-245e-08d7fb25eba0',
                        quantity: 1,
                        price: 20,
                        totalPrice: 20,
                        taxFreeTotalPrice: 35.4,
                        vin: 'vin12345',
                        saleDeliveryOrderDetailId: '4e2c5010-434e-4ede-a231-3d4140535aeb'
                    }
                ],
                pageSize: 2,
                pageIndex: 0,
                totalPages: 1,
                totalElements: 2
            },
        }
    );
});
router.post('/', (req, res) => {
    // 新增
    res.json(
        {
            message: '新增成功'
        }
    );
});
router.get('/:id', (req, res) => {
    // 查询CBU整车发运单详情
    const content = [];
    for(let i = 1; i <= 3; i++) content.push({
        partId: `${i}`,
        partCode: `CODE${i}`,
        partName: 'string',
        unit: 'ET',
        price: 10,
        orderQuantity: 10,
        remark: 'string'
    });
    res.json(
        {
            message: 'string',
            payload: {
                details: {
                    id: 'string',
                    code: 'string',
                    brandId: 'string',
                    brandCode: 'string',
                    brandName: 'string',
                    dealerId: 'string',
                    dealerCode: 'string',
                    dealerName: 'string',
                    ciCode: 'string',
                    partShipmentStatus: 1,
                    invoicedDate: '2020-03-17T07:26:02.665Z',
                    transportType: 1,
                    batchNumber: 'batchNumber',
                    origin: 'string',
                    destination: 'string',
                    actualShipmentDate: '2020-03-17T07:26:02.665Z',
                    expectDepartedDate: '2020-03-17T07:26:02.665Z',
                    expectShipmentDate: '2020-03-17T07:26:02.665Z',
                    shipmentDate: 'string',
                    expectShipmentDay: 10,
                    actualShipmentDay: 10,
                    actualDepartedDate: '2020-03-17T07:26:02.665Z',
                    expectArrivalDate: '2020-03-17T07:26:02.665Z',
                    actualArrivalDate: '2020-03-17T07:26:02.665Z',
                    shipmentNumber: 'string',
                    shippingCompanyAirline: 'string',
                    declarePlace: 1,
                    declareType: 1,
                    remark: 'string',
                    signnedRemark: 'string',
                    creatorName: 'string',
                    createTime: '2020-03-17T07:26:02.665Z',
                    modifierName: 'string',
                    modifyTime: '2020-03-17T07:26:02.665Z',
                    confirmerName: 'string',
                    confirmTime: '2020-03-17T07:26:02.665Z',
                    receipterName: 'string',
                    receiptTime: '2020-03-17T07:26:02.665Z',
                    rowVersion: 'string',
                    details: [
                        {
                            saleConfirmationId: 'string',
                            saleConfirmationrCode: 'string',
                            saleDeliveryOrderId: 'string',
                            saleDeliveryOrderCode: 'string',
                            saleDeliveryOrderDetailId: 'string',
                            productId: 'string',
                            productCode: 'string',
                            productName: 'string',
                            quantity: 0,
                            price: 0,
                            totalPrice: 0,
                            vin: 'string',
                        }
                    ],
                    attachments: [
                        {
                            fileId: '001',
                            fileName: 'fileName001'
                        }
                    ],
                    options: ['update', 'abandon', 'signned', 'dateSupplement']
                }
            }
        }
    );
});
router.put('/:id', (req, res) => {
    //修改
    res.json(
        {
            message: '修改成功'
        }
    );
});
router.put('/:id/abandon', (req, res) => {
    //签收
    res.json(
        {
            message: '成功签收'
        }
    );
});
router.put('/:id/signned', (req, res) => {
    //作废
    res.json(
        {
            message: '成功作废'
        }
    );
});
router.put('/:id/datesupplement', (req, res) => {
    //日期补录
    res.json(
        {
            message: '成功日期补录'
        }
    );
});
router.post('/import', (req, res) => {
    //发运单导入
    res.json({
        message: '导入成功'
    });
});
router.post('/importInfo', (req, res) => {
    //发运单导入返回信息
    res.json({
        message: '导入返回获取成功',
        payload: {
            content: [
                {
                    id: 'c60e0879-301f-4497-b4bf-59d91a68e74e',
                    saleShipmentId: '56ab0018-e592-4106-ba8c-e83ea9939954',
                    saleConfirmationId: '59a4508a-6db4-4c14-ca70-08d7cc72e90a',
                    saleConfirmationrCode: '15665-KD202003Normal0001',
                    saleDeliveryOrderDetailId: '353017ba-5108-460b-2d32-08d7cc770335',
                    productId: 'c127985e-eb97-4764-a2a3-b200ce9c661d',
                    productCode: 'A6462GAELBW0002',
                    productName: 'SQR6462A187开瑞黄基本型5座(国Ⅳ+OBD）',
                    quantity: 2,
                    price: 10,
                    totalPrice: 20,
                    taxFreeTotalPrice: null,
                    vin: '2'
                }
            ]
        }
    });
});
router.get('/importTemp', (req, res) => {
    res.json({
        message: '导入模版'
    });
});
module.exports = router;
